<?php
Class LoginController{
public $title;
public $index;
public $link;
public $page;
public $page_id;
public $type;

	public function __construct(){
		$this->layout = 'false';
	}

	public function IndexAction(){
		
    }
    public function LoginzaAction(){
		$request = getRequest::getInstance();
		/*if($request->isPost()){
			$token = $request->getVar('token', 'POST');
			if(!empty($token)){
				if(false === ($authData = file_get_contents('http://loginza.ru/api/authinfo?token='.$token))){
					$err = 'Ошибка получения данных';
				}else{
					$ad = json_decode($authData);
						if(isset($ad->name)){
							$data = array(
							'name' => $ad->name->first_name.' '.$ad->name->last_name,
							'uid' => $ad->uid,
							'url' => $ad->identity,
							'provider' => $ad->provider,
							'photo' => $ad->photo,
							'token' => $token
						);
						Df_Auth::clear("user");
						Df_Auth::write(array("user"=>$data));
						header('Location: /login/loginza.html');
					}
				}
			}*/
		//}else{
			$login = $request->getVar('login', 'GET');
			if(!empty($login) && $login=='logout'){
				Df_Auth::clear("user");
				$ref = $request->Referrer();
				if(!empty($ref)){
					header("location: /".$ref['path']);
				}else{
					header("location: /index.html");
				}
				//header('Location: /login/loginza.html');
			}
			/*$user = Df_Auth::read("user");
			if(isset($user['name'])){
				echo"Здравствуйте ".$user['name']." - <a href='/login/loginza?login=logout'>Выход</a>";
				echo"<br>".$user['photo'];
			}else{
				echo"Вы не авторизированы! - <a href='https://loginza.ru/api/widget?token_url=http://donnaliya.p.ht/login/loginza.html&providers_set=openid,vkontakte,odnoklassniki,facebook,twitter,google,mailru,yandex&lang=uk'>Авторизироватся</a>";
			}*/
		//}
    }
}
